#pragma once
#include <zmq.h>
#include <nlohmann/json.hpp>
#include <chrono>
#include <string>

using json = nlohmann::json;

class JsonRpcClient
{
  public:
    JsonRpcClient (const JsonRpcClient &) = delete;
    JsonRpcClient &operator= (const JsonRpcClient &) = delete;

    static JsonRpcClient &getInstance (const std::string &connect_addr);

    json call (const std::string &method, const json &params = json::array ());

  private:
    JsonRpcClient (const std::string &connect_addr);
    ~JsonRpcClient ();

    void *context_;
    void *socket_;
    int next_id_;
};